import { drawer_disable_ok_button, drawerInstance, operateType } from "./store";
import { drawerFormState, isExpand } from "@user/popular/store";
import {
  drawerLoading,
  drawerTitle,
  drawerVisible,
} from "@user/popular/drawer";
import FormItemComponent from "@user/popular/components/FormItemComponent";
import FooterComponent from "@user/popular/components/FooterComponent";
import { handleAction } from ".";
export const drawerConfig = () => {
  const defineDrawer = {
    width: "800px",
    drawerInstance,
    loading: drawerLoading,
    visible: drawerVisible,
    title: drawerTitle,
    maskClosable: true,
    formState: drawerFormState,
    disable_ok_button: drawer_disable_ok_button,
    event: {
      cancel: () => (isExpand.value = false),
    },
    slot: {
      extra_form_item: () => <FormItemComponent />,
      extra: () => {
        return drawerFormState.status === 1 ? (
          <a-space size={8}>
            {withDirectivePower({
              vNode: (
                <s-button
                  icon={renderIcon("icon-reject")}
                  loading={drawerLoading.value}
                  type="default"
                  onClick={async () => {
                    handleAction({ type: "refuse" });
                    isExpand.value = false;
                  }}
                >
                  {$t("base.refuse")}
                </s-button>
              ),
              bindingValue: "authApi.updateReject",
            })}

            {withDirectivePower({
              vNode: (
                <s-button
                  icon={renderIcon("icon-jushou1")}
                  loading={drawerLoading.value}
                  type="primary"
                  onClick={async () => {
                    handleAction({ type: "agree" });
                    isExpand.value = false;
                  }}
                >
                  {$t("base.agree")}
                </s-button>
              ),
              bindingValue: "authApi.updatePass",
            })}

            {operateType.value === "view" ? (
              <s-button
                icon={renderIcon("icon-tubiao_tijiao")}
                type="primary"
                onClick={() => {
                  drawerVisible.value = false;
                  isExpand.value = false;
                }}
              >
                {$t("base.ok")}
              </s-button>
            ) : null}
          </a-space>
        ) : (
          <s-button
            icon={renderIcon("icon-tubiao_tijiao")}
            type="primary"
            onClick={() => {
              drawerVisible.value = false;
              isExpand.value = false;
            }}
          >
            {$t("base.ok")}
          </s-button>
        );
      },
    },
  };
  return defineDrawer;
};
